/*
Copyright (C) Ariff Ehsan, Abdul Hadi Fikri

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*  Author : Ariff Ehsan
 *  Date   : June 27, 2009
 */


#ifndef __BUTTON_H__
#define __BUTTON_H__


enum button_state_enums {
	BUTTON_RELEASED = 0,
	BUTTON_RELEASING,
	BUTTON_PUSHED,
	BUTTON_PUSHING,
};


typedef struct button_t {
	
	uint8_t state;
	
	uint8_t* port;
	uint8_t pin;
	
	void (*event)(uint8_t state);
	
	struct button_t* next;
	
} button_t;


void BUTTON_init(void);
void BUTTON_reg(button_t*, uint8_t* port, uint8_t pin, void (*)(uint8_t));
void BUTTON_start(button_t*);

#endif // __BUTTON_H__